package com.foreknow.domo11;

import java.awt.*;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.Reader;

/**
 * 多态实际中的应用
 */
public class Application {

    public void m1(Reader reader) {

    }

    public Component m2() {
//        Button button = new Button("登录");
        Checkbox checkbox = new Checkbox();
        return checkbox;
    }

    public void m3() {
        Component[] arr = new Component[2];  //定义一个Component类型(父类型)的数组  多态
        Button b1 = new Button("按钮1");
        Button b2 = new Button("按钮2");
        arr[0] = b1; // 添加元素的时候可以保存Component子类的对象
        arr[1] = b2;
    }

    public static void main(String[] args) throws FileNotFoundException {
        Application application = new Application();
        FileReader fileReader = new FileReader("");
        application.m1(fileReader);

        Checkbox component = (Checkbox) application.m2();

    }
}
